﻿using Domain.Models;
using Domain.SeedData;
using Microsoft.EntityFrameworkCore;
using System.Linq;

namespace Domain.Context
{
    public partial class RepositoryContext
    {
        /// <summary>
        ///  初始化数据
        /// </summary>
        /// <param name="modelBuilder"></param>
        private void InitSeedData(ModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<Group>().HasData(InitGroup.InitData());
            var account = InitAccount.InitData();
            modelBuilder.Entity<Account>().HasData(account);

            var role = InitRole.InitData();
            modelBuilder.Entity<Role>().HasData(role);

            //modelBuilder.Entity<AccountGroup>().HasData(InitAccountGroup.InitData());

            modelBuilder.Entity<AccountRole>().HasData(InitAccountRole.InitData(account.First().Id, role.First().Id));

            //modelBuilder.Entity<GroupRole>().HasData(InitGroupRole.InitData());

            modelBuilder.Entity<Navigation>().HasData(InitNavigation.InitData());
            var permissions = InitPermission.InitData();
            modelBuilder.Entity<Permission>().HasData(permissions);
            modelBuilder.Entity<RolePermission>().HasData(InitRolePermission.InitData(permissions.First().Id, role.First().Id));

            //modelBuilder.Entity<PermissionNavigation>().HasData(InitPermissionNavigation.InitData());

            modelBuilder.Entity<Dicts>().HasData(InitDicts.InitData());

        }

    }
}
